Skip to content

Comments

feat: prefetch image related fields in event API#1154

Open
sentry[bot] wants to merge 1 commit intomainfrom
seer/feat/prefetch-event-images
Open

feat: prefetch image related fields in event API#1154
sentry[bot] wants to merge 1 commit intomainfrom
seer/feat/prefetch-event-images

Conversation

@sentry
Copy link

@sentry sentry bot commented Jan 30, 2026

Fixes LINKEDEVENTS-4. The issue was that: EventSerializer's nested field access triggers N+1 queries due to incomplete prefetch_related in EventViewSet's queryset.

  • Add prefetching for image-related fields in the event API.
  • Prefetches created_by, data_source, last_modified_by, license, and publisher for images when 'images' are included in the request.
  • Improves performance by reducing database queries for image-related data.

This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 594568

Not quite right? Click here to continue debugging with Seer.

@mhieta mhieta force-pushed the seer/feat/prefetch-event-images branch from a62b6e2 to 9a7addf Compare January 30, 2026 07:06
@azure-pipelines
Copy link

LINKEDEVENTS-API branch is deployed to platta: https://linkedevents-pr1154.api.dev.hel.ninja 🚀🚀🚀

@mhieta mhieta marked this pull request as ready for review January 30, 2026 07:34
@mhieta mhieta requested a review from a team as a code owner January 30, 2026 07:34
@azure-pipelines
Copy link

LINKEDEVENTS-API branch is deployed to platta: https://linkedevents-pr1154.api.dev.hel.ninja 🚀🚀🚀

@mhieta
Copy link
Contributor

mhieta commented Jan 30, 2026

@sentry review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an N+1 query problem in the EventSerializer by adding prefetch optimization for image-related fields when the include=images parameter is used in the event API.

Changes:

  • Added prefetch_related for image foreign key relationships (created_by, data_source, last_modified_by, license, publisher) in the EventViewSet
  • Added comprehensive test coverage to verify the prefetch optimization prevents N+1 queries when listing multiple events with images

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
events/api.py Adds prefetch_related optimization for image-related fields in the _optimize_include method
events/tests/test_event_get.py Adds test to verify that query count remains constant when adding more events with images

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mhieta mhieta force-pushed the seer/feat/prefetch-event-images branch from 9a7addf to 9a26aa7 Compare January 30, 2026 14:49
@azure-pipelines
Copy link

LINKEDEVENTS-API branch is deployed to platta: https://linkedevents-pr1154.api.dev.hel.ninja 🚀🚀🚀

@mhieta mhieta force-pushed the seer/feat/prefetch-event-images branch from 9a26aa7 to 209d0ed Compare February 10, 2026 08:56
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant